import { createRouter, createWebHashHistory } from 'vue-router'
import { LOGIN_ROUTE_NAME, HOME_ROUTE_NAME } from '@/router/constants'
import Layout from '@/layout/index.vue'

const privateRoutes = [
  {
    path: '/user',
    component: Layout,
    name: 'user',
    redirect: '/user/manage',
    meta: {
      title: 'user',
      icon: 'UserOutlined'
    },
    children: [
      {
        path: '/user/manage',
        name: 'UserManage',
        component: () => import('@/views/user/user-manage.vue'),
        meta: {
          title: 'userManage',
          icon: 'UserSwitchOutlined'
        }
      },
      {
        path: '/user/role',
        name: 'role',
        component: () => import('@/views/role-list/index'),
        meta: {
          title: 'roleList',
          icon: 'TeamOutlined'
        }
      },
      {
        path: '/user/permission',
        name: 'permission',
        component: () => import('@/views/permission-list/index'),
        meta: {
          title: 'permissionList',
          icon: 'SisternodeOutlined'
        }
      },
      {
        path: '/user/info/:id',
        name: 'userInfo',
        component: () => import('@/views/user-info/index'),
        meta: {
          title: 'userInfo',
          icon: 'SolutionOutlined',
          menuShow: false
        }
      }
    ]
  }
]

const publicRoutes = [
  {
    path: '/login',
    name: LOGIN_ROUTE_NAME,
    component: () => import('@/views/login/LoginView.vue'),
    meta: {
      title: 'login'
    }
  },
  {
    path: '/',
    component: Layout,
    redirect: '/home',
    children: [
      {
        path: '/home',
        name: HOME_ROUTE_NAME,
        component: () => import('@/views/home/HomeView.vue'),
        meta: {
          title: 'home',
          icon: 'BankOutlined',
          menuShow: false
        }
      }
    ]
  }
]
const router = createRouter({
  history: createWebHashHistory(),
  routes: [...publicRoutes, ...privateRoutes]
})
export default router
